#include <iostream>
#include <vector>
using namespace std;

class Solution2 {
public:
    const int MOD = 1e9 + 7;

    int waysToStep(int n)
    {
        if (n == 1 || n == 2)
            return n;
        if (n == 3)
            return 4;

        vector<long long> dp(n + 1);
        dp[0] = 0, dp[1] = 1; dp[2] = 2, dp[3] = 4;

        for (int i = 4; i <= n; ++i)
        {
            dp[i] = ((dp[i - 1] + dp[i - 2]) % MOD + dp[i - 3]) % MOD;
        }

        return dp[n];
    }
};

class Solution1 {
public:
    int tribonacci(int n)
    {
        if (n == 0)
            return 0;
        if (n == 1 || n == 2)
            return 1;

        int a = 0, b = 1, c = 1;
        int sum = a + b + c;
        for (int i = 4; i <= n; ++i)
        {
            a = b;
            b = c;
            c = sum;
            sum = a + b + c;
        }
        return sum;
    }
};

int main()
{
    cout << Solution1().tribonacci(100) << endl;
    cout << Solution2().waysToStep(33) << endl;

    return 0;
}